#include "Map_Cell.h"

//Constructor/Destructor
Map_Cell::Map_Cell()
	:m_icon(' '), m_terrainFlags(0)
{

}

Map_Cell::~Map_Cell()
{

}
//Game Loop functions
void Map_Cell::draw()
{
	int drawColor;
	if (isVisible() == true){
		drawColor = m_color | FORE_INTENSE;
	} else {
		drawColor = m_color;
	}
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), drawColor);
	putchar(m_icon);
}
//Manipulators
void Map_Cell::setIcon(char a_char)
{
	m_icon = a_char;
}

void Map_Cell::setColor(int a_color){
	m_color = a_color;
}

void Map_Cell::setVisible(bool a_bool)
{
	if (a_bool == true)
		m_terrainFlags |= VISIBLE;
	else
		m_terrainFlags &= ~VISIBLE;
}

void Map_Cell::toggleVisible()
{
	m_terrainFlags = m_terrainFlags ^ VISIBLE;
}

void Map_Cell::setMapped(bool a_bool)
{
	if (a_bool == true)
		m_terrainFlags |= MAPPED;
	else
		m_terrainFlags &= ~MAPPED;
}

void Map_Cell::toggleMapped()
{
	m_terrainFlags = m_terrainFlags ^ MAPPED;
}

void Map_Cell::setPassable(bool a_bool)
{
	if (a_bool == true)
		m_terrainFlags |= PASSABLE;
	else
		m_terrainFlags &= ~PASSABLE;
}

void Map_Cell::togglePassable()
{
	m_terrainFlags = m_terrainFlags ^ PASSABLE;
}
//Accessors
char Map_Cell::getIcon()
{
	return m_icon;
}

bool Map_Cell::isVisible()
{
	if(m_terrainFlags & VISIBLE)
		return true;
	else
		return false;
}

bool Map_Cell::isMapped()
{
	if(m_terrainFlags & MAPPED)
		return true;
	else
		return false;
}

bool Map_Cell::isPassable()
{
	if(m_terrainFlags & PASSABLE)
		return true;
	else
		return false;
}